package com.ecommerce.payment.client;

import com.ecommerce.payment.dto.ThirdPartyPaymentResult;
import com.ecommerce.payment.entity.Payment;
import com.ecommerce.payment.dto.CreatePaymentRequest;
import org.springframework.stereotype.Component;

/**
 * 支付宝支付客户端
 */
@Component
public class AlipayClient {

    /**
     * 创建支付
     *
     * @param payment 支付实体
     * @param request 创建支付请求
     * @return 第三方支付结果
     */
    public ThirdPartyPaymentResult createPayment(Payment payment, CreatePaymentRequest request) {
        ThirdPartyPaymentResult result = new ThirdPartyPaymentResult();
        // 模拟支付宝支付逻辑
        result.setSuccess(true);
        result.setThirdPartyPaymentNo("ALI" + System.currentTimeMillis());
        result.setAmount(request.getAmount().toString());
        // 模拟支付URL
        result.setExtraParams("https://alipay.com/pay/" + payment.getPaymentNo());
        return result;
    }
}